package com.day8;

import java.util.Comparator;
import java.util.TreeSet;

public class b {
    public static void main(String[] args) {
        Comparator<Teacher> cc = new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int a = o1.getAge() - o2.getAge();
                int b = a == 0 ? o1.getName().compareTo(o2.getName()) : a;
                return b;
            }
        };
        TreeSet<Teacher> tc = new TreeSet<>(cc);
        Teacher t1 = new Teacher("zhangsan", 23);
        Teacher t2 = new Teacher("zhangsan", 22);
        Teacher t3 = new Teacher("lisi", 23);
        Teacher t4 = new Teacher("zhangsan", 23);
        Teacher t5 = new Teacher("wanwu", 20);
        tc.add(t1);
        tc.add(t2);
        tc.add(t3);
        tc.add(t4);
        tc.add(t5);
        System.out.println(tc);
    }
}
